/**
 * 有安全区就将组件高度设置为安全区高度，否则将高度设置20px对应的rpx值
 */
Component({
  data: {
    classNameArr: ["safety-area-top-height"],
  },
  lifetimes: {
    ready() {
      this.updateCompHeight();
    },
  },
  methods: {
    updateCompHeight() {
      const query = wx.createSelectorQuery().in(this);
      const that = this;
      query
        .select(`.safety-area-top-height`)
        .boundingClientRect((rect) => {
          console.log("rect.height", rect.height);
          if (rect.height === 0) {
            console.log("iiiiiiiiii");
            const classNameArr = [...this.data.classNameArr];
            classNameArr.push("original-bar-height");
            that.setData({ classNameArr }, () => {
              console.log("jjjjjjjjjjjjjjj");
              that.triggerEvent("mounted");
            });
          } else {
            console.log("kkkkkkkkkkkk");
            that.triggerEvent("mounted");
          }
        })
        .exec();
    },
  },
});
